#include "UiDownBar.h"


extern HINSTANCE					g_SDHResModuleHandle;
UiDownBar::UiDownBar()
{
}

UiDownBar::~UiDownBar()
{
}

BOOL UiDownBar::InitUiWin(HWND hWnd)
{
	BOOL bRtn = FALSE;
	LoadiInterItem();

	HDC hdc = GetDC(hWnd);
	m_hBakDC = CreateCompatibleDC(hdc);
	m_hBitmapBakDC = CreateCompatibleBitmap(hdc, GetWidth(), GetHeight());
	HGDIOBJ oldbmp = SelectObject(m_hBakDC, m_hBitmapBakDC);

	RECT rcWin = GetRect();
	RECT prcWin = {0, 0, rcWin.right-rcWin.left, rcWin.bottom-rcWin.top};
	RECT prcUpdate = prcWin;
	OnPaint(m_hBakDC, &prcWin, &prcUpdate);

	ReleaseDC(hWnd, hdc);
	return bRtn;
}

void UiDownBar::PaintWin(HDC hdc, RECT* prcWin, RECT* prcUpdate)
{

	m_DownBarBG->Draw(hdc, prcWin, false, false);

}

int UiDownBar::OnLButtonDown(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonDown(fwKeys, xPos, yPos);

}

int UiDownBar::OnLButtonUp(UINT fwKeys, int xPos, int yPos)
{
	return UiWin::OnLButtonUp(fwKeys, xPos, yPos);

}



BOOL UiDownBar::InitImages()
{
	return TRUE;
}

void UiDownBar::LoadiInterItem()
{
	m_DownBarBG = ImagingHelper::GetImageObject(g_SDHResModuleHandle, 9521);

	RECT rtDownBarBtn[MAX_DOWNBAR_BTN] = {
		140,10,206,79,
		240,10,306,79,
		40,10,106,79,
		340,10,406,79,
	};

	m_BtnDwonBar[VIDEO_DOWNBAR_PLAY].SetPos(rtDownBarBtn[VIDEO_DOWNBAR_PLAY].left, rtDownBarBtn[VIDEO_DOWNBAR_PLAY].top, 
		rtDownBarBtn[VIDEO_DOWNBAR_PLAY].right-rtDownBarBtn[VIDEO_DOWNBAR_PLAY].left, 
		rtDownBarBtn[VIDEO_DOWNBAR_PLAY].bottom-rtDownBarBtn[VIDEO_DOWNBAR_PLAY].top);
	m_BtnDwonBar[VIDEO_DOWNBAR_PLAY].SetID(8600);
	m_BtnDwonBar[VIDEO_DOWNBAR_PLAY].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9500, true));
	m_BtnDwonBar[VIDEO_DOWNBAR_PLAY].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9501, true));
	AddChild(&m_BtnDwonBar[VIDEO_DOWNBAR_PLAY]);

	m_BtnDwonBar[VIDEO_DOWNBAR_STOP].SetPos(rtDownBarBtn[VIDEO_DOWNBAR_STOP].left, rtDownBarBtn[VIDEO_DOWNBAR_STOP].top, 
		rtDownBarBtn[VIDEO_DOWNBAR_STOP].right-rtDownBarBtn[VIDEO_DOWNBAR_STOP].left,
		rtDownBarBtn[VIDEO_DOWNBAR_STOP].bottom-rtDownBarBtn[VIDEO_DOWNBAR_STOP].top);
	m_BtnDwonBar[VIDEO_DOWNBAR_STOP].SetID(8601);
	m_BtnDwonBar[VIDEO_DOWNBAR_STOP].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9517, true));
	m_BtnDwonBar[VIDEO_DOWNBAR_STOP].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9516, true));
	AddChild(&m_BtnDwonBar[VIDEO_DOWNBAR_STOP]);

	m_BtnDwonBar[VIDEO_DOWNBAR_PREV].SetPos(rtDownBarBtn[VIDEO_DOWNBAR_PREV].left, rtDownBarBtn[VIDEO_DOWNBAR_PREV].top, 
		rtDownBarBtn[VIDEO_DOWNBAR_PREV].right-rtDownBarBtn[VIDEO_DOWNBAR_PREV].left, 
		rtDownBarBtn[VIDEO_DOWNBAR_PREV].bottom-rtDownBarBtn[VIDEO_DOWNBAR_PREV].top);
	m_BtnDwonBar[VIDEO_DOWNBAR_PREV].SetID(8602);
	m_BtnDwonBar[VIDEO_DOWNBAR_PREV].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9508, true));
	m_BtnDwonBar[VIDEO_DOWNBAR_PREV].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9509, true));
	AddChild(&m_BtnDwonBar[VIDEO_DOWNBAR_PREV]);

	m_BtnDwonBar[VIDEO_DOWNBAR_NEXT].SetPos(rtDownBarBtn[VIDEO_DOWNBAR_NEXT].left, rtDownBarBtn[VIDEO_DOWNBAR_NEXT].top, 
		rtDownBarBtn[VIDEO_DOWNBAR_NEXT].right-rtDownBarBtn[VIDEO_DOWNBAR_NEXT].left,
		rtDownBarBtn[VIDEO_DOWNBAR_NEXT].bottom-rtDownBarBtn[VIDEO_DOWNBAR_NEXT].top);
	m_BtnDwonBar[VIDEO_DOWNBAR_NEXT].SetID(8603);
	m_BtnDwonBar[VIDEO_DOWNBAR_NEXT].SetNormalImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9510, true));
	m_BtnDwonBar[VIDEO_DOWNBAR_NEXT].SetPressedImage(ImagingHelper::GetImageObject(g_SDHResModuleHandle,9511, true));
	AddChild(&m_BtnDwonBar[VIDEO_DOWNBAR_NEXT]);


	RECT rtProgress = {525, 24, 715, 48};
	m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME].SetPos(rtProgress.left, rtProgress.top,
		rtProgress.right-rtProgress.left, 
		rtProgress.bottom-rtProgress.top);
	m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME].SetStyle(SliderBar);
	m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME].SetID(8604);
	m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME].SetSliderBitmap( ImagingHelper::GetImageObject(g_SDHResModuleHandle,9514, true),
															ImagingHelper::GetImageObject(g_SDHResModuleHandle,9515, true),
															ImagingHelper::GetImageObject(g_SDHResModuleHandle,9519, true),
															24, 24);
	m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME].SetPadpos( 0 );
	AddChild(&m_slideBar[VIDEO_DOWNBAR_STATUSBAR_VOLUME]);


}
